﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using LibraryO2S;


public partial class administrator_Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (Session["username"] != null)
        //{
        //    Response.Redirect("ControlPannel.aspx");
        //}
    }
    //tblAccount Admin = new tblAccount();
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string username = txtUser.Value;
        string password = txtPassword.Value;
        //if (Admin.CheckLogin(username.Trim(), password.Trim()))
        //{
        //    WriteCookie();
        //    Session["username"] = username;
        //    Response.Redirect("ControlPannel.aspx");
        //} 
        if ("admin".Equals(username) && "123456".Equals(password))
        {
            Session["username"] = username;
            Response.Redirect("ControlPannel.aspx");
        }
        else
        {
            divMessages.InnerHtml = O2S_Message.Warning("Cảnh báo", "Tài khoản và tên đăng nhập không đúng");
        }

    }
    private void WriteCookie()
    {
        if (cbremember.Checked)
        {
            HttpCookie cookie = new HttpCookie("cookiename");
            cookie.Values.Add("UserName", txtUser.Value);
            cookie.Values.Add("Password", txtPassword.Value);
            cookie.Expires = DateTime.Now.AddDays(30);
            Response.Cookies.Add(cookie);
        }
    }

}
